package com.openwater;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.widget.ProgressBar;

public class MyPrograssBar extends ProgressBar {

    public MyPrograssBar(Context context, AttributeSet attrs) {
        super(context, attrs);
        mPaint = new Paint();
        mLineHeight = 2.0f;
        mProgressHeight = 10.0f;
    }

    private Paint mPaint;
    private float mLineHeight;
    private float mProgressHeight;

    @Override
    protected synchronized void onDraw(Canvas canvas) {
        mPaint.setColor(Color.DKGRAY);
        mPaint.setStrokeWidth(mLineHeight);
        canvas.drawLine(0, (getHeight() + mLineHeight + mProgressHeight) / 2.0f, getWidth(),
                (getHeight() + mLineHeight + mProgressHeight) / 2.0f, mPaint);

        mPaint.setColor(Color.GRAY);
        mPaint.setStrokeWidth(mProgressHeight);
        canvas.drawLine(0, getHeight() / 2.0f, getProgress() * 1.0f / getMax() * getWidth(),
                getHeight() / 2.0f, mPaint);
    }
}
